from flask import Flask, redirect
from config import DevelopmentConfig


def create_app():
    app = Flask("yanyu")
    app.config.from_object(DevelopmentConfig)
    app = reg_blueprint(app)
    # 打印路由
    print(app.url_map)

    return app


def reg_blueprint(app):
    
    # 展示页面
    from web.public import blueprint as public_blueprint
    app.register_blueprint(public_blueprint)    #  url_prefix="/www"
    # 后台管理界面
    from web.backend import blueprint as backend_blueprint
    app.register_blueprint(backend_blueprint)   # url_prefix="/admin"

    return app
